<!--用户的提现流水页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-button v-if="$hasPermission('api:getCashOutRate:info')" type="primary"@click="userCashoutRate(Rate.id)">提现配置</el-button>
        </el-form-item>
        <el-form-item prop="id">
          <el-input v-model="dataForm.id" placeholder="请输入提现ID" clearable></el-input>
        </el-form-item>
        <el-form-item prop="status">
          <ren-select v-model="dataForm.payStatus" dict-type="pay_status" placeholder="请选择打款状态"></ren-select>
        </el-form-item>
        <el-form-item prop="paymentName">
          <el-input v-model="dataForm.bankUsername" placeholder="请输入收款人姓名" clearable></el-input>
        </el-form-item>
        <el-form-item prop="paymentNo">
          <el-input v-model="dataForm.bankNumber" placeholder="请输入收款人账号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker
              v-model="createDateList"
              type="daterange"
              placeholder="请选择创建日期"
              format="yyyy 年 MM 月 dd 日"
              range-separator="至"
              start-placeholder="开始创建日期"
              end-placeholder="结束创建日期"
              value-format="yyyy-MM-dd"
              class=""
              @change="createCK"
          />
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
        <el-form-item v-if="$hasPermission('api:exportUserCashout:export')">
          <el-button @click="exportHandle()" type="info">导出</el-button>
        </el-form-item>
<!--                <el-form-item>-->
<!--                  <el-button v-if="$hasPermission('api:userCashout:save')" type="primary"-->
<!--                             @click="addOrUpdateHandle()">-->
<!--                    新增-->
<!--                  </el-button>-->
<!--                </el-form-item>-->
<!--                <el-form-item>-->
<!--                  <el-button v-if="$hasPermission('api:userCashout:delete')" type="danger" @click="deleteHandle()">-->
<!--                    删除-->
<!--                  </el-button>-->
<!--                </el-form-item>-->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="userId" label="用户ID" header-align="center" align="center" width="220">
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>用户信息</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <div class="flex_rows flex_center" @click="showUserList(row['userDTO'])" v-if="row['userDTO']">
              <el-avatar size="large" :src="row['userDTO']['avatar']"></el-avatar>
              <div class="flex_columns" style="margin-left: 10px;">
                <div class="flex_rows" style="text-decoration: underline;cursor: pointer;">ID:{{row['userDTO']['id']}}</div>
                <div class="flex_rows flex_center" style="text-decoration: underline;cursor: pointer;">
                  <div class="ellipsis1" style="max-width: 4em;">
                    {{row['userDTO']['nickname']}}
                  </div>
                  ({{row['userDTO']['identity']}})
                </div>
              </div>
            </div>
            <div v-if="!row['userDTO']">{{row.userId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="applyAmount" label="提现金额" header-align="center" align="center" width="">
          <template slot-scope="{row}">
            <div>{{formatNumber(row.applyAmount)}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="rate" label="手续费" header-align="center" align="center" width="">
          <template slot-scope="{row}">
            <div>{{formatNumber(row.rate)}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="actualAmount" label="实际金额" header-align="center" align="center" width="">
          <template slot-scope="{row}">
            <div>{{formatNumber(row.actualAmount)}}</div>
          </template>
        </el-table-column>
<!--        <el-table-column prop="applyRemark" label="提现备注" header-align="center" align="center" width="" show-overflow-tooltip></el-table-column>-->
        <el-table-column prop="bankUsername" label="收款人姓名" header-align="center" align="center" width=""></el-table-column>
        <el-table-column prop="bankName" label="银行名称" header-align="center" align="center" width=""></el-table-column>
        <el-table-column prop="bankBranch" label="支行名称" header-align="center" align="center" width="140">
          <template slot-scope="{row}">
            <el-tooltip  effect="dark" :content="row.bankBranch" placement="top">
              <div class="ellipsis2">{{ row.bankBranch }}</div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="bankNumber" label="银行卡号" header-align="center" align="center" width="">
          <template slot-scope="{row}">
            <el-tooltip  effect="dark" :content="row.bankNumber" placement="top">
              <div class="ellipsis2">{{ row.bankNumber }}</div>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="payStatus" label="打款状态" header-align="center" align="center" sortable width="110">
          <template slot-scope="{row}">
            <el-tag v-if="row.payStatus === '1'" size="small" type="success">
              {{ $getDictLabel("pay_status", row.payStatus)}}
            </el-tag>
            <el-tag v-else-if="row.payStatus === '2'" size="small" type="danger">
              {{ $getDictLabel("pay_status", row.payStatus)}}
            </el-tag>
            <el-tag v-else size="small" type="info">
              {{ $getDictLabel("pay_status", row.payStatus)}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="proof" label="打款凭证" header-align="center" align="center" width=""></el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center" width="100"></el-table-column>
        <el-table-column label="操作" fixed="right" header-align="center" align="center" width="">
          <template slot-scope="scope">
            <el-link v-if="$hasPermission('api:userCashout:update') && $getDictLabel('pay_status', scope.row.payStatus) === '0'"
                     type="primary"
                     @click="addOrUpdateHandle(scope.row.id)">打款
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!--查看用户信息组件-->
      <com-user-list :visible.sync="showUser" :content="content"></com-user-list>
      <!-- 提现配置信息 -->
      <user-cashout-rate v-if="showCashoutRate" ref="userCashoutRate"></user-cashout-rate>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userCashoutAddOrUpdate.vue'
import userCashoutRate from './userCashoutRateAddOrUpdate.vue'
import {formatNumber} from "@/utils";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/userCashout/page',
        getDataListIsPage: true,
        deleteURL: '/api/userCashout',
        deleteIsBatch: true,
        exportURL: '/api/userCashout/exportUserCashout'             // 导出接口，API地址
      },
      showCashoutRate:false,            //是否显示提现配置信息
      showUser:false,                   //是否显示用户信息
      content:{},                       //用户信息内容
      createDateList: [],               //创建时间数组
      dataForm: {
        id: '',                         //id
        actualAmount:'',                //实际金额
        applyAmount: '',                //提现金额
        applyRemark: '',                //提现备注
        bankBranch: '',                 //支行名称
        bankName: '',                   //银行名称
        bankNumber: '',                 //银行卡号
        bankUsername: '',               //收款人姓名
        createDate: '',                 //创建时间
        createDateStart: '',            //开始创建时间
        createDateEnd: '',              //结束创建时间
        payStatus: '',                  //待支付;已支付
        proof: '',                      //付款凭证
        rate: '',                       //提现手续费
        userId: '',                     //用户编号
      },
      Rate:{                            //提现配置数据
        id: '',                         //id
        cashoutRate:'',                 //提现手续费
        cashoutRateDesc: '',            //字段说明
      }
    }
  },
  components: {
    AddOrUpdate,
    userCashoutRate
  },
  created() {

  },
  methods: {
    formatNumber,
    /*创建时间选择*/
    createCK() {
      if (!this.createDateList){
        this.dataForm.createDateStart = ''
        this.dataForm.createDateEnd = ''
        return
      }
      this.dataForm.createDateStart = this.createDateList[0]
      this.dataForm.createDateEnd = this.createDateList[1]
    },
    //显示用户信息
    showUserList(content){
      this.showUser=true;
      this.content= content;
    },
    // 提现配置新增 / 修改
    userCashoutRate (id) {
      this.showCashoutRate = true
      this.$nextTick(() => {
        this.$refs.userCashoutRate.dataForm.id = id
        this.$refs.userCashoutRate.init()
      })
    },
  }
}
</script>
